//
//  HCRePwdViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/3/1.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCRePwdViewController.h"

@interface HCRePwdViewController () {
    UITextField *name;
    HCPopLoadingView *mine_hud;
}

@end

@implementation HCRePwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataRequest.delegate = self;
    self.textTitle = @"修改密码";
    [self setRightButtonText:@"保存"];
    [self setLeftButtonImage:@"happy_mine_LBackIMG"];
    
    self.centerView.frame = CGRectMake(self.centerView.frame.origin.x, self.centerView.frame.origin.y, self.centerView.frame.size.width, self.centerView.frame.size.height+49);
    
    name = [[UITextField alloc] initWithFrame:CGRectMake(5, 10, self.centerView.frame.size.width - 10, 40)];
    name.placeholder = @"请输入密码";
    name.borderStyle = UITextBorderStyleRoundedRect;
    name.secureTextEntry = YES;
    [self.centerView addSubview:name];
    
    UILabel *promptLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 51, self.centerView.frame.size.width-10, 20)];
    promptLabel.textColor = [UIColor blackColor];
    promptLabel.font = YBKSystemFont(YBKAdaptiveFont(9));
    promptLabel.text = @"最多只能输入6个字符";
    [self.centerView addSubview:promptLabel];
    
    mine_hud = [[HCPopLoadingView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // Do any additional setup after loading the view.
}

-(void)rightBtnAction:(UIButton *)btn {
    if ([PublicFunction isNull:name.text]) {
        [XHToast showBottomWithText:@"密码不能为空"];
    }else{
        [mine_hud showAnimate];
        [self.dataRequest postHC_MineMsgEdit:HCGETUSER(@"userid") message:name.text withType:EDT_PWD];
    }
}

-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    [mine_hud hidden];
    if ([dictionary[@"stat"] integerValue] == 200) {
        [self.navigationController popViewControllerAnimated:YES];
        [XHToast showBottomWithText:@"密码修改成功"];
    }else{
        [XHToast showBottomWithText:@"密码修改成功"];
    }
}

-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {
    [mine_hud hidden];
    [XHToast showBottomWithText:@"网络请求失败"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
